package com.linkage.bookshop.authentication;

import javax.servlet.http.HttpServletRequest;

import org.springframework.security.core.context.SecurityContextImpl;
import org.springframework.stereotype.Component;

@Component
public class CrendentialSessionService {
	public String getUsername(HttpServletRequest request) {
		SecurityContextImpl securityContextImpl = (SecurityContextImpl) request.getSession().getAttribute("SPRING_SECURITY_CONTEXT");
		if(securityContextImpl == null){
			return null;
		}
		return securityContextImpl.getAuthentication().getName();
	}
}
